package com.draw.server.gui;

import java.awt.BorderLayout;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;

import com.draw.server.Loader;
import com.draw.server.gui.panel.ColorPanel;
import com.draw.server.gui.panel.WordPanel;
import com.draw.server.gui.panel.HomePanel;

public class Window extends JFrame implements WindowListener {
	private static final long serialVersionUID = -144384065966684389L;
	private static Window instance = null;

	public static Window getInstance() {
		if (instance == null) {
			instance = new Window();
		}
		return instance;
	}
	
	public Window() {
		super();
		new Loader();
		this.addWindowListener(this);
		this.setTitle("DrawServer");
		this.setSize(700, 500);

		JTabbedPane tabbed = new JTabbedPane();
		tabbed.add("Accueil", HomePanel.getInstance());
		tabbed.add("Mots", WordPanel.getInstance());
		tabbed.add("Couleurs", ColorPanel.getInstance());
		
		this.setLayout(new BorderLayout());
		this.add(tabbed,BorderLayout.CENTER);
		
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}
	
	public static void main(String[] args) {
		new Window();
	}

	@Override
	public void windowOpened(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowClosing(WindowEvent e) {
		HomePanel hp = HomePanel.getInstance();
		hp.stopServer();
	}

	@Override
	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowIconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowDeiconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowDeactivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}
}
